<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>编辑《 ${detail.name}》</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/jquery-3.2.1.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script>
        $(function () {
            $('#header').load('admin_header.html');
        });
    </script>
</head>
<body background="../../static/img/book2.jpg" style=" background-repeat:no-repeat ;
background-size:100% 100%;
background-attachment: fixed;">

<div id="header" style="padding-bottom: 80px"></div>

<div class="col-xs-6 col-md-offset-3" style="position: relative;">
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">编辑《 ${detail.name}》</h3>
        </div>
        <div class="panel-body">

            <c:choose>
            <c:when test="${ not empty classId}">
                <form action="book_edit_do.html?bookId=${detail.bookId}&classId=${classId}&currentPage=${currentPage}" method="post" id="addbook">
                </c:when>
                <c:when test="${not empty bookName}">
                    <form action="book_edit_do.html?bookId=${detail.bookId}&bookName=${bookName}&currentPage=${currentPage}" method="post" id="addbook">
                    </c:when>
                    <c:otherwise >
                        <form action="book_edit_do.html?bookId=${detail.bookId}&currentPage=${currentPage}" method="post" id="addbook">
                        </c:otherwise>
                        </c:choose>

                                <table class="table table-hover">
                    <tbody>
                    <tr>
                        <th width="15%">书名</th>
                        <td><input type="text" class="form-control" name="name" id="name" value="${detail.name}"></td>
                    </tr>
                    <tr>
                        <th>作者</th>
                        <td><input type="text" class="form-control" name="author" id="author" value="${detail.author}">
                        </td>
                    </tr>
                    <tr>
                        <th>出版社</th>
                        <td><input type="text" class="form-control" name="publish" id="publish"
                                   value="${detail.publish}"></td>
                    </tr>
                    <tr>
                        <th>ISBN</th>
                        <td><input type="text" class="form-control" name="isbn" id="isbn" value="${detail.isbn}"></td>
                    </tr>
                    <tr>
                        <th>简介</th>
                        <td><input type="text" class="form-control" name="introduction" id="introduction"
                                   value="${detail.introduction}"></td>
                    </tr>
                    <tr>
                        <th>语言</th>
                        <td>
                            <select class="form-control" name="language" id="language" }>
                                <option ${detail.language eq '中文'?'selected':''} value="中文">中文</option>
                                <option ${detail.language eq '英语'?'selected':''} value="英语">英语</option>
                                <option ${detail.language eq '日语'?'selected':''} value="日语">日语</option>
                                <option ${detail.language eq '德语'?'selected':''} value="德语">德语</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>价格</th>
                        <td><input type="number" class="form-control" name="price" id="price" value="${detail.price}">
                        </td>
                    </tr>
                    <tr>
                        <th>出版日期</th>
                        <td><input type="date" class="form-control" name="pubstr" id="pubstr"
                                   value=<fmt:formatDate value="${detail.pubdate}" pattern="yyyy-MM-dd "/>></td>
                    </tr>
                    <tr>
                        <th>分类号</th>
                        <td><input type="number" class="form-control" name="classId" id="classId" min="1" max="22"
                                   value="${detail.classId}"></td>
                    </tr>
                    <tr>
                        <th>数量</th>
                        <td><input type="number" class="form-control" name="number" id="number" min="0"
                                   value="${detail.number}"></td>
                    </tr>
                    </tbody>
                </table>
                <%--按钮--%>
                <input type="submit" value="确定" class="btn btn-success btn-sm" class="text-left">
                <%--<a href="admin_books.html">
                    <button type="button" class="btn btn-success btn-sm">取消</button>
                </a>--%>
                    <input type="button" class="btn btn-success btn-sm"  value="取消" onclick="javascript:history.go(-1);"/>
                <%--填入信息不能有空白--%>
                <script>
                    $("#addbook").submit(function () {
                        if ($("#name").val() == '' || $("#author").val() == '' || $("#publish").val() == '' || $("#isbn").val() == '' || $("#introduction").val() == '' || $("#price").val() == '' || $("#classId").val() == '' || $("#number").val() == '') {
                            alert("请填入完整图书信息！");
                            return false;
                        }
                    })
                </script>
            </form>
        </div>
    </div>

</div>

</body>
</html>

<%--管理员     编辑图书--%>